﻿<%@ Page Title="" Language="C#" MasterPageFile="~/template_faa/master/faa_main.Master" AutoEventWireup="true" %>

<asp:Content ID="Content4" ContentPlaceHolderID="head" runat="server">
    <link rel="stylesheet" type="text/css" href="../ascx/easyui/demo/demo.css"/>
    <link rel="stylesheet" type="text/css" href="../css/left_nav.css"/>
    <script type="text/javascript" src="../scripts/datagrid-detailview.js"></script>
    <script type="text/javascript" src="../scripts/left_nav.js"></script>
    
    <script type="text/javascript" id="for datagrid">
        $(document).ready(
            function() {
                loadGrid();
            }
        );

        function loadGrid() {
            $('#dataGrid_id').datagrid({
                width: 'auto',
                height: 365,
                idField: 'id',                          //表明该列是一个唯一列    
                striped: true,                          //设置为true将交替显示行背景
                singleSelect: true,                     //设置为true将只允许选择一行
                url: 'getTHCTHType.ashx',               //用以从远程站点请求数据的超链接地址
                loadMsg: '数据加载中请稍后……',         //当从远程站点载入数据时，显示的一条快捷信息
                pagination: true,                       //设置true将在数据表格底部显示分页工具栏
                rownumbers: false,                       //设置为true将显示行数
                toolbar: '#dataGrid_toolbar_id',        //工具栏
                columns: [[                              //数据表格列配置对象
                    {field: 'thclxId', title: '类型编号', align: 'center', width: 80 },
                    { field: 'thclxName', title: '类型名称', align: 'center', width: 80 },
                    { field: 'admin', title: '操作', align: 'center', width: 100,
                        formatter: function(value, rec, index) {
                            var e = '<a href="#" onclick="editItem(this);">编辑</a> ';
                            var d = '<a href="#" onclick="deleteItem(this);">删除</a> ';
                            return e + " | " + d;
                        }
                    }
                ]]
            });
        }
    </script>

    <script language="javascript" type="text/javascript" id="for dialog">
        var curUrl = "";
        
        //打开新增对话框
        function addItem() {
            $('#dataGrid_dialog_id').dialog('open').dialog('setTitle', '新建通航处通航月报生产类型');
            $('#dataGrid_dialog_form_id').form('clear');
            curUrl = "saveTHCTHType.ashx"; 
        }

        function importItems() {
            alert("从Excel导入数据");
        }

        //打开编辑对话框
        function editItem(cur) {
            var rowIndex = getRowNumber(cur);
            var row = $('#dataGrid_id').datagrid("getRows")[rowIndex];
            if (row) {
                $('#dataGrid_dialog_id').dialog('open').dialog('setTitle', '编辑通航处通航月报生产类型');
                $('#dataGrid_dialog_form_id').form('load', row);
                curUrl = 'updateTHCTHType.ashx';
            }
        }

        //执行删除条目
        function deleteItem(cur) {
            var rowIndex = getRowNumber(cur);
            var row = $('#dataGrid_id').datagrid("getRows")[rowIndex];
            if (row) {
                $.messager.confirm('Confirm', '真的要删除吗？', function(r) {
                    if (r) {
                        $.post('deleteTHCTHType.ashx', { thclxId: row.thclxId }, function(result) {
                            if (result == 'SUCCESS') {
                                $('#dataGrid_id').datagrid('reload');    // reload the user data  
                            } else {
                                $.messager.show({   // show error message  
                                    title: 'Error',
                                    msg: '删除数据失败'
                                });
                            }
                        }, 'text');
                    }
                });
            }
        }

        //执行保存条目
        function saveItem() {
            $('#dataGrid_dialog_form_id').form('submit', {
                url: curUrl,
                onSubmit: function() {
                    return $(this).form('validate');
                },
                success: function(result) {
                    if (result == "FAILURE") {
                        $.messager.show({
                            title: 'Error',
                            msg: '保存数据失败'
                        });
                    } else {
                        $('#dataGrid_dialog_id').dialog('close');      // close the dialog
                        $('#dataGrid_id').datagrid('reload');    // reload the user data  
                    }
                }
            });
        }
        
        function getRowNumber(cur) {
            var rows = $(cur).parents("table").find("tr");
            var row = $(cur).parents("tr");
            var rowNumber = -1;

            for ( var i = 0; i < rows.length; i++ ) {
                if (row.is(rows[i])) {
                    rowNumber = i;
                    break;
                }
            }

            return rowNumber; 
        }

    </script>
    
</asp:Content>
<asp:Content ID="Content1" ContentPlaceHolderID="body_left" runat="server">
    <div id="navigator">
        <ul id="listUL">
            <li><a href="#">基元系统管理</a></li>
            <li><a href="#">行政检查管理</a>
                <ul class="myHide">
                    <li><a href="#">1</a></li>
                    <li><a href="#">2</a></li>
                </ul>
            </li>
            <li><a href="#">统计分析管理</a>
                <ul class="myHide">
                    <li><a href="#">执法统计管理</a></li>
                    <li><a href="#">安全统计管理</a></li>
                    <li><a href="#">生产统计管理</a></li>
                </ul>
            </li>
            <li><a href="#">用户管理</a>
                <ul class="myHide">
                    <li><a href="#">用户信息管理</a></li>
                    <li><a href="#">用户权限管理</a></li>
                </ul>
            </li>
            <li><a href="#">信息发布管理</a></li>
        </ul>
    </div>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="body_right_top" runat="server">
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="body_right_bottom" runat="server">
    <!--主表格-->
    <table id="dataGrid_id" title="通航生产类型管理-通航处"></table>         
    
    <!--主表格工具栏-->
    <div id="dataGrid_toolbar_id">
        <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-add" plain="true" onclick="addItem();">新增</a>  
        <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-add" plain="true" onclick="importItems()">导入</a>  
    </div>
    
    <!--弹出对话框-->
    <div id="dataGrid_dialog_id" class="easyui-dialog" style="width:400px;height:200px;padding:10px" closed="true" buttons="#dlg-buttons">
        <form id="dataGrid_dialog_form_id" method="post" novalidate>
            <div class="form_title">通航处通航月报生产类型</div> 
            <table>
                <tr>
                    <td>
                        类型ID：
                    </td>
                    <td>
                        <input class="easyui-validatebox" type="text" name="thclxId" data-options="required:true"></input>
                    </td>
                </tr>
                <tr>
                    <td>
                        类型名称：
                    </td>
                    <td>
                        <input class="easyui-validatebox" type="text" name="thclxName" data-options="required:true"></input>
                    </td>
                </tr>
            </table>
        </form>
        
    </div>  
        
    <!--弹出对话框底部按钮-->
    <div id="dlg-buttons">  
        <a href="javascript:void(0)" class="easyui-linkbutton" onclick="saveItem()">保存</a>  
        <a href="javascript:void(0)" class="easyui-linkbutton" onclick="$('#dataGrid_dialog_form_id').form('clear')">重置</a>  
        <a href="javascript:void(0)" class="easyui-linkbutton" onclick="$('#dataGrid_dialog_id').dialog('close')">取消</a>  
    </div>

</asp:Content>
